package qlsl.androiddesign.adapter.subadapter;

import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.entity.otherentity.CarDetail;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.TextSizeUtils;

/**
 * 个人发布二手车列表<br/>
 *
 */
public class MemberPublishAdapter extends BaseAdapter<CarDetail> {

	public MemberPublishAdapter(BaseActivity activity, List<CarDetail> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_member_publish);

		ImageView iv_icon = getView(convertView, R.id.iv_icon);
		TextView tv_name = getView(convertView, R.id.tv_name);
		TextView tv_info = getView(convertView, R.id.tv_info);
		TextView tv_price = getView(convertView, R.id.tv_price);
		TextView tv_time = getView(convertView, R.id.tv_time);

		CarDetail item = getItem(position);
		String single = activity.getString(R.string.single);
		String name = item.getMachinevision() + single + item.getModelno();
		String price = "价格：￥" + item.getPrice();
		String info = item.getUsedtime() + "小时 / " + item.getProvince() + " " + item.getCity();
		String time = item.getYears();

		ImageUtils.rectOri(activity, item.getPhotourl(), iv_icon);
		tv_name.setText(name);
		tv_info.setText(info);
		TextSizeUtils.setText(tv_price, price, 3, price.length(), 14,
				activity.getResources().getColor(R.color.half_red));
		tv_time.setText(time);

		return convertView;
	}
}
